package com.toman.ui.my;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.toman.R;
import com.toman.toolbar.ToolBarWhiteActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AboutUsActivity extends ToolBarWhiteActivity {

    @BindView(R.id.iv_logo)
    ImageView ivLogo;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_content)
    TextView tvContent;
    @BindView(R.id.tv_hint)
    TextView tvHint;
    @BindView(R.id.btn_phone)
    Button btnPhone;
    @BindView(R.id.tv_code)
    TextView tvCode;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us2);
        ButterKnife.bind(this);
        initToolBar("");
        initView();

    }

    private void initView() {
        try {
            tvCode.setText(getVersionName());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


    private String getVersionName() throws Exception {
        // 获取packagemanager的实例
        PackageManager packageManager = getPackageManager();
        // getPackageName()是你当前类的包名，0代表是获取版本信息
        PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(), 0);
        String version = packInfo.versionName;
        return "版本号："+version;
    }

    @OnClick(R.id.btn_phone)
    public void onViewClicked() {
        Intent intent = new Intent(Intent.ACTION_DIAL);
        Uri data = Uri.parse("tel:" + btnPhone.getText().toString());
        intent.setData(data);
        startActivity(intent);
    }
}
